/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package xdxn.editor.studio.geom;

/**
 *
 * @author Cai Han
 */
public class Rect2D {

    public int x;
    public int y;
    public int width;
    public int height;

    public Rect2D(int x, int y, int width, int height) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
    }

    public boolean contains(Rect2D rectangle) {
        return (contains(rectangle.x, rectangle.y)
                && contains(rectangle.x + rectangle.width, rectangle.y)
                && contains(rectangle.x, rectangle.y + rectangle.height)
                && contains(rectangle.x + rectangle.width, rectangle.y + rectangle.height));
    }

    public boolean contains(int x, int y) {
        return (x >= this.x && x <= this.x + this.width && y >= this.y && y <= this.y + this.height);
    }
}
